With the arrival of the age of the post personal computer (PC), embedded systems have been widely applied in key technical fields with higher reliability requirement, such as communication, aviation, national defense and industrial control, and the complexity and functions of the embedded systems increase gradually. Meanwhile, in order to utilize resources effectively, software design methods with parallel multi-application and multi-task are also adopted generally. These changes cause the increase of various faults and exceptions in the systems inevitably. When an exception occurs, if it is not handled effectively, it may cause termination of application program and system breakdown, and may even trigger disastrous accidents, which is unwilling to see.
As a common mechanism for an embedded system fault-tolerance, exception handling plays a very important role in guaranteeing the reliability of the embedded systems, but the conventional exception handling mechanism can no longer meet the development requirement of the present embedded systems.
The conventional exception handling in the embedded system adopts a manner which is similar to interrupt response, and when an exception occurs, the processor will simply store the exception site, and jump to the corresponding exception handling function by searching the exception vector table. This exception handling mechanism is closely related to the hardware architecture of the processor, in which a large number of assembly codes need to be used for writing the exception handling program to operate the register. Meanwhile, for each exception to be captured, the exception handling program has to be modified correspondingly according to the architecture of the processor, which results in poor portability and robustness of the exception handling program.
The reliability of the systems will be decreased without handling exceptions, while defective or invalid exception handling may also cause serious system faults. As the functions of the embedded systems increase continuously, multiple applications are often running in a system, and each application is composed of several tasks, wherein a task is a minimum unit that can be scheduled by the operating system and executed by the processor and that can compete for system resources, and the task can be ran independently to complete a certain relatively independent function. The conventional exception handling mechanism only performs process for tasks; if the exception handling program itself has defects or is unable to handle the occurred exception, the system will be unable to identify and resolve the exception, and the exception of a single task may spread to the application program to which the task belongs, and then influence the stable operation of the whole system.
The publication of Chinese patent application 200610104447 discloses a method for monitoring and handling exceptions for a computer application program, in which a method for monitoring and handling exceptions is provided, which can monitor not only the working condition of the application program but also each module in the program, and can perform process for program exceptions. The publication of Chinese patent application CN03157874 discloses an exception monitoring device for a multi-task system and a method thereof, in which an exception monitoring device for a multi-task system and a method thereof are provided, which extends the range of exception monitoring from single-task to multi-task, allowing to realize the functions of the exception monitoring and the automatic reset to normal operation condition in the multi-task system. Above invention patent applications have refined and extended the range of the exception monitoring, but the exception handling strategy is simplex, and secondary exceptions during the process for handling exceptions are not solved, thus exception spread may be still possible. The secondary exception is relate to an exception occurred in the exception handling program itself during the execution of the exception handling program.
The U.S. invention patent “Exception analysis methods and systems” disclosed by the publication of the U.S. patent application US2007022321 provides an exception analysis method for embedded system, which classifies exceptions that occur during the running of the system, but provides no exception handling strategy. The U.S. invention patent “Handling exceptions” disclosed by the publication of the U.S. patent application US2005015579 discloses an embedded device for handling exceptions, which comprises an exception recorder, an intelligent recovery agent and a post-exception analysis tool. Wherein, the exception recorder is used for recording information related to the exception, the intelligent recovery agent is used for detecting exceptions and determining a proper handling way to be adopted, and the post-exception analysis tool is responsible for identifying the cause of the exception. However, the intelligent recovery agent is unable to distinguish the defects of the method itself for handling exceptions and unable to solve the problems that the method for handling exceptions is invalid and the secondary exception problem.
In conclusion, the existing method for handling exceptions can no longer meet the change of the present embedded systems; a new exception handling mechanism has to be introduced to guarantee the reliable and stable operation of the systems.